import java.math.*;

import static java.lang.Math.pow;

public class 四叶玫瑰 {
    public static void main(String[] args) {
        for (int i = 1000; i <10000 ; i++) {
            int ge = i%10;
            int shi = i%100/10;
            int bai = i/100%10;
            int qian = i/1000;
            int num;
            num = (int) (pow(ge,4)+pow(shi,4)+pow(bai,4)+pow(qian,4));
            if(num==i){
                System.out.println(i);
            }
        }
    }
}
